<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Creating, retrieving, updating and deleting data</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="sdodasrel.examples.html">范例</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="sdodasrel.metadata.html">Specifying the metadata</a></div>
 <div class="up"><a href="sdodasrel.examples.html">范例</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="sdodasrel.examples-crud" class="section">
  <h2 class="title">Creating, retrieving, updating and deleting data</h2>
  <p class="para">
   This section illustrates how the Relational DAS can be used to create, 
   retrieve, update and delete data in a relational database.
   Many of the examples are illustrated with a three-table database that 
   contains companies, departments within those companies, and employees 
   that work in those departments. This example is used in a number of 
   places within the SDO literature. See the examples section of the
   <a href="ftp://www6.software.ibm.com/software/developer/library/j-commonj-sdowmt/Commonj-SDO-Specification-v2.0.pdf" class="link external">&raquo;&nbsp;Service Data Objects specification</a>
   or the
   <a href="sdo.examples.html" class="link">Examples</a>
   section of the documentation for the SDO extension.
  </p>

  <p class="para">
   The Relational DAS is constructed with metadata that defines the 
   relational database and how it should be mapped to SDO.
   The long section that follows describes this metadata and how to 
   construct the Relational DAS. The examples that follow it all assume that
   this metadata is in an included php file.
  </p>

  <p class="para">
   The examples below and others can all be found in the
   <var class="filename">Scenarios</var>
   directory in the Relational DAS package.
  </p>

  <p class="para">
   The Relational DAS throws exceptions in the event that it finds errors 
   in the metadata or errors when executing SQL statements against the 
   database. For brevity the examples below all omit the use of try/catch 
   blocks around the calls to the Relational DAS.
  </p>

  <p class="para">
   These examples all differ from the expected use of SDO in two
   important respects.
  </p>
  <p class="para">
   First, they show all interactions with the database completed within 
   one script. In this respect these scenarios are not realistic but are 
   chosen to illustrate just the use of the Relational DAS.
   It is expected that interactions with the database will be separated 
   in time and the data graph serialized and deserialized into the PHP 
   session one or more times as the application interacts with an end user.
  </p>
  <p class="para">
   Second, all queries executed against the database use hard-coded 
   queries with no variables substituted. In this case it is safe to 
   use the simple 
   <span class="function"><strong>executeQuery()</strong></span>
   call, and this is what the examples illustrate. 
   In practice, though, it is unlikely that the SQL statement is known 
   entirely ahead of time. In order to allow variables to be safely 
   substituted into the SQL queries, without running the risk of 
   injecting SQL with unknown effects, it is safer to use the 
   <span class="function"><strong>executePreparedQuery()</strong></span>
   which takes a prepared SQL statement containing placeholders
   and a list of values to be substituted. 
  </p>
 </div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="sdodasrel.examples.html">范例</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="sdodasrel.metadata.html">Specifying the metadata</a></div>
 <div class="up"><a href="sdodasrel.examples.html">范例</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
